package com.naiterui.ehp.bs.file.api.feign;

import java.util.Collection;
import java.util.Map;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import com.naiterui.ehp.bp.support.config.FeignConfiguration;
import com.naiterui.ehp.bs.file.api.bo.FileBO;
import com.naiterui.ehp.bs.file.api.bo.FileParamBO;
import com.naiterui.ehp.bs.file.api.exception.FileException;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

/**
 * 文件Feign接口类
 * 
 * @author yangfuya
 * @since 2021/9/10
 */
@FeignClient(name = "file", url = "${ehp.domain.file}", configuration = FeignConfiguration.class)
public interface FileFeignClient {

    @ApiOperation("生成预览Url")
    @PostMapping("/inner/generate/preview")
    FileBO generatePreview(@RequestBody FileParamBO fileParamBO) throws FileException;

    @ApiOperation("批量生成预览Url")
    @PostMapping("/inner/batch/generate/preview")
    Map<String, FileBO> batchGeneratePreview(@RequestBody FileParamBO fileParamB) throws FileException;

    @ApiOperation("生成下载Url")
    @PostMapping("/inner/generate/download")
    FileBO generateDownload(@RequestBody FileParamBO fileParamB) throws FileException;

    @ApiOperation("获取文件真实路径")
    @ApiImplicitParam(name = "url", value = "安全url", required = true, dataType = "string", paramType = "form")
    @GetMapping("/inner/real/path")
    String getRealPath(@RequestParam("url") String url) throws FileException;

    @ApiOperation("批量获取文件真实路径")
    @ApiImplicitParam(name = "urls", value = "安全url列表", required = true, dataType = "list", paramType = "body")
    @PostMapping("/inner/batch/real/path")
    Map<String, FileBO> batchRealPath(@RequestBody Collection<String> urls) throws FileException;
}
